
package cn.xabad.commons.plist;

import java.io.IOException;
import java.io.InputStream;
import java.lang.String;


public class PListXMLParser extends BaseXMLParser {

	public static final String TAG = "PListXMLParser";

	
	public PListXMLParser() {
		super();
	}

	
	public void parse(String xml) throws IllegalStateException {
		PListXMLHandler pListHandler = (PListXMLHandler) getHandler();
		if (null == pListHandler) {
			throw new IllegalStateException(
					"handler is null, must set a document handler before calling parse");
		}
		if (null == xml) {
			pListHandler.setPlist(null);
			return;
		}
		initParser();
		super.parse(xml);
	}

	
	public void parse(InputStream is) throws IllegalStateException, IOException {
		PListXMLHandler pListHandler = (PListXMLHandler) getHandler();
		if (null == pListHandler) {
			throw new IllegalStateException(
					"handler is null, must set a document handler before calling parse");
		}
		if (null == is) {
			pListHandler.setPlist(null);
			return;
		}
		Stringer xml = null;
		try {
			xml = Stringer.convert(is);
		} catch (IOException e) {
			throw new IOException(
					"error reading from input string - is it encoded as UTF-8?");
		}
		initParser();
		super.parse(xml.getBuilder().toString());
	}

}
